﻿namespace GroupChallenge.Web
{
    // Partial class with extra validation logic from the RIA service POCO objects.
    public partial class Player
    {
        // Get the lowered nickname to identify in a dictionary.
        internal string LoweredNickName
        {
            get
            {
                if (!string.IsNullOrEmpty(NickName))
                    return NickName.ToLowerInvariant();

                return NickName;
            }
        }

        // Validate the player's nickname to play with.
        internal string Validate()
        {
            string ret = string.Empty;

            // Remove spaces.
            if (!string.IsNullOrEmpty(NickName))
            {
                NickName = NickName.Trim();
            }

            // Missing now?
            if (string.IsNullOrEmpty(NickName))
            {
                ret = "Nickname is missing.  Please enter a nickname.";
            }

            return ret;
        }
    }
}